{% set selectedVersion = (nodejs.settings.version is defined and nodejs.settings.version)
    ? nodejs.settings.version
    : false %}
{% set versions = selectedVersion
    ? merge_unique([selectedVersion], nodejs.available.versions)
    : nodejs.available.versions %}

<input type="hidden" name="nodejs[install]" value="0" />

<div class="container-fluid cm-container-white section-title">
    <div class="checkbox checkbox-lg no-padding">
        <input type="checkbox" id="nodejs-install"
               name="nodejs[install]" value="1"
               {% if nodejs.install %}checked{% endif %}
               data-toggle="checkbox-collapse" data-target="#nodejs-container" />
        <label for="nodejs-install">Install Node.js</label>

        <p>
            A platform for easily building fast, scalable network applications.
        </p>
    </div>
</div>

<div id="nodejs-container"
     class="container-fluid collapse {% if nodejs.install %}in{% endif %}">
    <div class="panel panel-default">
        <div class="panel-body">
            <div class="form-group col-xs-12 col-sm-6">
                <label for="nodejs-settings-version">
                    Node.js Version
                </label>
                <select id="nodejs-settings-version"
                        name="nodejs[settings][version]"
                        class="form-control select-tag">
                    {% for version in versions %}
                        <option value="{{ version }}"
                            {% if version == selectedVersion %}selected{% endif %}>{{ version }}</option>
                    {% endfor %}
                </select>
                <div class="help-block">
                    CentOS 6 support has been dropped.
                </div>
            </div>

            <div class="form-group col-xs-12 col-sm-6">
                <label for="nodejs-npm_packages">
                    Install Npm Packages
                </label>
                <select id="nodejs-npm_packages"
                        name="nodejs[npm_packages][]"
                        multiple class="form-control select-tags-editable">
                    {% for package in nodejs.npm_packages %}
                        <option selected value="{{ package }}">{{ package }}</option>
                    {% endfor %}
                </select>
                <div class="help-block">
                    <p>To install a specific version, use <code>{package}@{version}</code>.</p>
                    <p>eg: <code>express@4.10.4</code>. For latest just use <code>{package}</code>.</p>
                </div>
            </div>

            <div class="clearfix"></div>
        </div>
    </div>

    <div class="clearfix"></div>
</div>

<div class="container-fluid cm-container-white section-footer">
    <a href="#python" data-toggle="tab" class="btn btn-primary btn-lg pull-left">
        <i class="fa fa-arrow-left" aria-hidden="true"></i>
        Python
    </a>

    <a href="#mariadb" data-toggle="tab" class="btn btn-primary btn-lg pull-right">
        MariaDB
        <i class="fa fa-arrow-right" aria-hidden="true"></i>
    </a>
</div>
